package com.sitech.component.tree;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.sitech.context.SpringContext;
import com.sitech.webapp.action.BaseAction;

public class TreeAction extends BaseAction
{
	
	private static final long serialVersionUID = 1610644983330893427L;
	private String nodeId;
	private List<? extends Node> tree;
	private TreeService treeService;
	private String serviceName;
	
	public String tree()
	{
		if(serviceName != null && !serviceName.equals(""))
		{
			treeService = (TreeService) SpringContext.getBean(serviceName);
		}
		if(nodeId != null && !"".equals(nodeId) && !TreeService.ROOT_NODE_ID.equals(nodeId) && !"UNDEFINED".equals(nodeId.toUpperCase()))
		{
			tree = treeService.querySubNode(nodeId);
		}
		else
		{
			tree = treeService.queryRootNode();
		}
		return SUCCESS;
	}
	
	public List<? extends Node> getTree()
	{
		return tree;
	}

	public void setTree(List<Node> tree)
	{
		this.tree = tree;
	}

	public String getNodeId()
	{
		return nodeId;
	}

	public void setNodeId(String nodeId)
	{
		this.nodeId = nodeId;
	}

	public void setTreeService(TreeService treeService)
	{
		this.treeService = treeService;
	}

	public String getServiceName()
	{
		return serviceName;
	}

	public void setServiceName(String serviceName)
	{
		this.serviceName = serviceName;
	}
	
}
